package cn.cdeden.knowledge.controller.unified;

import cn.cdeden.common.core.domain.R;
import cn.cdeden.knowledge.domain.TreeNodeDirectory;
import cn.cdeden.knowledge.domain.dto.TreeNodeParam;
import cn.cdeden.knowledge.service.FilesTreeService;
import io.undertow.util.BadRequestException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 文档树公用接口
 */
@Controller
@Slf4j
//@Api(tags = "文档树公用接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/unifiedCollection")
public class FilesTreeController {


    private final FilesTreeService filesTreeService;


    /**
     * 跳转树目录
     * @param id
     * @param fileType
     * @return
     */
    @GetMapping(value = "/getParentTreeNodeAll")
    @ResponseBody
    public R getParentTreeNodeAll(@RequestParam String id, @RequestParam String fileType) throws BadRequestException {
        return R.ok(filesTreeService.getParentTreeNodeAll(id,fileType));
    }


    /**
     * 文件:跳转树目录
     * @param query
     * @return
     */
//    @Log("文件:跳转树目录")
//    @ApiOperation("文件:跳转树目录" )
    @GetMapping(value = "/new/getParentTreeNodeAll")
    @ResponseBody
    public R getNewParentTreeNodeAll(TreeNodeParam query) throws BadRequestException {

        TreeNodeDirectory tree = filesTreeService.getNewParentTreeNodeAll(query);

        return R.ok(tree);
//        return BaseRespResult.successResult(tree);
    }

}
